Skip to content

pass --gc-sections if -Zexport-executable-symbols is enabled and improve tests #143846

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

usamoi
Copy link
Contributor

@usamoi usamoi commented Jul 12, 2025

Exported symbols are added as GC roots in linking, so --gc-sections won't hurt -Zexport-executable-symbols.

Fixes the run-make test to work on Linux. Enable the ui test on more targets.

cc #84161

@rustbot rustbot added A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 12, 2025
}
cmd.gc_sections(keep_metadata);
} else {
cmd.no_gc_sections();
Copy link
Contributor Author

@usamoi usamoi Jul 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removed line is the only place in rustc where no_gc_sections is called, so I had to call it here to suppress the unused warning.

@usamoi usamoi marked this pull request as ready for review July 12, 2025 17:53
@rustbot
Copy link
Collaborator

rustbot commented Jul 12, 2025

r? @jieyouxu

rustbot has assigned @jieyouxu.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 12, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 12, 2025

This PR modifies run-make tests.

cc @jieyouxu

Some changes occurred in compiler/rustc_codegen_ssa

cc @WaffleLapkin

@jieyouxu
Copy link
Member

Maybe r? @bjorn3 (or reroll)

@rustbot rustbot assigned bjorn3 and unassigned jieyouxu Jul 13, 2025
.invalid_stdout_utf8();
assert_contains(&output, "exported_symbol");
} else {
let output = llvm_readobj().symbols().input(bin_name("main")).run().invalid_stdout_utf8();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussion: Hm, this might not be quite right for windows msvc, cc @ChrisDenton ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

llvm-readobj indeed cannot read symbols from MSVC-generated artifacts. I just switched to using the object crate to read the exports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants